<?php
require_once('../include/db_settings.php');

$conn = mysql_connect($db_host, $db_user, $db_pwd);

if (!$conn) {
    die("could not connect:" . mysql_error());
}

if (mysql_query("CREATE DATABASE IF NOT EXISTS crazy_blog default charset utf8 COLLATE utf8_general_ci;", $conn)) {
    echo "db created.";
} else {
    echo "error creating db:" . mysql_error();
}

mysql_select_db($db_name, $conn);

$sql = "CREATE TABLE blog
(
id int not null auto_increment,
title varchar(100),
content varchar(2000),
post_date datetime,
PRIMARY KEY(id)
)";


$result = mysql_query($sql, $conn);
if(!$result){
    echo "error creating table: " . mysql_error();

} else
    echo "result: " . $result;

$sql = "CREATE TABLE todo
(
  id int(11) NOT NULL AUTO_INCREMENT,
  content varchar(2000) NOT NULL,
  duration int(4) default 0,
  expense float default 0,
  appear_after datetime DEFAULT NULL,
  priority int(4) DEFAULT 1,
  post_date datetime DEFAULT NULL,
  complete_date datetime DEFAULT NULL,
  status varchar(10) NOT NULL DEFAULT 'new',
  PRIMARY KEY (id)
)";


$result = mysql_query($sql, $conn);
if(!$result){
    echo "error creating table: " . mysql_error();

} else
    echo "result: " . $result;

mysql_close($conn);

